package electricity.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import electricity.domain.EquipmentRepair;
import electricity.dto.RepairDto;
import electricity.mapper.EquipmentRepairMapper;
import electricity.service.RepairService;
import electricity.vo.PageResult;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RepairServiceImpl implements RepairService {

    @Autowired
    private EquipmentRepairMapper equipmentRepairMapper;

    @Override
    public PageResult pageQuery(RepairDto repairDto) {
        PageHelper.startPage(repairDto.getPage(), repairDto.getPageSize());
        Page<EquipmentRepair> page = equipmentRepairMapper.pageQuery(repairDto);
        return new PageResult(page.getTotal(), page.getResult());

    }

    @Override
    public void updateProcessor(Integer repairId, Integer processorId) {
        equipmentRepairMapper.updateProcessor(repairId, processorId);
    }

    @Override
    public void update(EquipmentRepair equipmentRepair) {
        equipmentRepairMapper.updateByPrimaryKey(equipmentRepair);
    }
}
